package com.xiaoq.shop.service.impl;

import com.xiaoq.shop.entity.ShopPayTypeEntity;
import com.xiaoq.shop.repository.IShopPayTypeRepository;
import com.xiaoq.shop.service.IShopPayTypeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShopPayTypeServiceImpl implements IShopPayTypeService{

    @Autowired
    private IShopPayTypeRepository shopPayTypeRepository;

    @Override
    public boolean save(ShopPayTypeEntity shopPayTypeEntity) {
        return shopPayTypeRepository.save(shopPayTypeEntity);
    }

    @Override
    public boolean updateByShopId(ShopPayTypeEntity shopPayTypeEntity) {
        return shopPayTypeRepository.updateById(shopPayTypeEntity);
    }

    @Override
    public ShopPayTypeEntity getByShopId(String shopId) {
        if(StringUtils.isBlank(shopId)){
            return null;
        }
        ShopPayTypeEntity shopPayTypeEntity = new ShopPayTypeEntity();
        shopPayTypeEntity.setShopId(shopId);
        return shopPayTypeRepository.getByCommon(shopPayTypeEntity);
    }
}
